#ifndef _UTILS_H_
#define _UTILS_H_

#include <vector>
#include <string>
#include <boost/property_tree/ptree.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <boost/thread/locks.hpp>

using namespace std;
using namespace boost::property_tree;

class Utils
{
private:
	static locale *_p_locale;
	static locale *_p_milli_locale;
	static vector<int> *_p_id_vector;
	static boost::shared_mutex *_p_id_mutex;

public:
	static void Str2StrList(string &str, vector<string> &strList, char splitChar);
	static int GZCompress(const char *data, unsigned long ndata, char *zdata, unsigned long *nzdata);
	static int GZDecompress(char *zdata, unsigned long nzdata, char *data, unsigned long *ndata);
	static int ZCompress(const char *data, unsigned long ndata, char *zdata, unsigned long *nzdata);
	static int ZDecompress(char *zdata, unsigned long nzdata, char *data, unsigned long *ndata);
	static int GetUniqueId();
	static int TimeStr2MilliSec(string &time_str);
	static int TimeStr2Seconds(string &time_str);
	static string MilliSec2TimeStr(int milli_seconds);
	static string Seconds2TimeStr(int seconds);
	static void CreateMultiPlayerTree(vector<int> &player_list, ptree &format_tree);
//	static void CreateMultiPlayerBuf(vector<int> &player_list, int &len, char *buf);
//	static int CreateMulticastInfo(vector<int> &player_list, ptree &tree, int character_id,
//        int format, int &len, char *buf);
    static int Distence(int x1, int y1, int x2, int y2);
};

#endif
